/*
 * Copyright (c) China Telecom Cloud Technology Co., Ltd. 2024-2025. All rights reserved.
 */
#include "Common.h"
#include <sys/time.h>


uint64_t getCurrentTimestampUs() {
    struct timeval tv;
    gettimeofday(&tv, nullptr);
    return static_cast<uint64_t>(
                tv.tv_sec) * MICROSECONDS_PER_SECOND 
               + tv.tv_usec;  // 微秒
}




double calculatePercentage(const int a, const int b) {
    if (b == 0) {
        return 0.0;  // 或者抛出异常
    }
    return (static_cast<double>(a) / b) * PERCENTAGE_MULTIPLIER;
}